#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define sz(s) int(s.size())
typedef long long ll;
typedef pair<int, int> pii;

const int N = 2e5 + 10;
const ll mod = 1e9 + 7;
ll a[N];

void solve()
{
	ll n, k;
	cin >> n >> k;
	for(int i = 1;i <= n; i ++ ) a[i] = i;
	if(k % 2 == 1)
	{
		cout << "NO" << endl;
		return;
	}
	ll r = n, l = 1;
	while(l < r && k > 0)
	{
		if(k > 2 * (r - l))
		{
			swap(a[l], a[r]);
			k -= 2 * (r - l);
			l ++;
			r --;
		}
		else
		{
			k /= 2;
			r = l + k;
			swap(a[l], a[r]);
			k -= (r - l);
		}
	}
	if(k > 0) cout << "NO" << endl;
	else
	{
		cout << "YES" << endl;
		for(int i = 1;i <= n; i ++ ) cout << a[i] << " ";
		cout << endl;
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	int T = 1;
	cin >> T;
	while(T --) solve();
	return 0;
}
